<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;
use Think\Controller;
use Think\Page;
class ActController extends CommonController {
    
	public function info(){
    	$id=$_GET['id'];
    	$art = D('Act'); // 
    	$art-> where('id='.$id)->setInc('hits');//点击数 字段加1
    	$arr=$art->find($id);
		$this->assign('data',$arr);
		$this->assign('now',strtotime('now'));
		
		$this->display('Act/act');
    }
    
    
    
	public function index(){
			
		$art = M('Act'); // 实例化User对象
		
		$title = $_GET['keyword'];
		$map['status'] = array('eq','0');
		if($title){
			$map['title'] = array('like','%'.$title.'%'); 
			$parameter=array(
				'keyword'=>$title,
			);
		}
		
		$count      = $art-> where($map)->count();// 查询满足要求的总记录数
		$Page       = new Page($count,15,$parameter);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$list = $art-> where($map) -> limit($Page->firstRow.','.$Page->listRows)->order('created_at desc')->select();
		$this->assign('data',$list);// 赋值数据集
		$this->assign('page',$show);// 赋值分页输出
		
		$mcate = M('ArticleCate');
		$catelist = $mcate->order('orderby')->select();
		$this->assign('catelist',$catelist);
		
		$this->assign('keyword',$title);
		
		$this->display('Act/index');
	}
    
}